<!doctype html><html class="use-motion" lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="google-site-verification" content="0axhmy0-lA3xPbR8wPgyWlMZjwWSCfagKukdyeCQ7LU"><link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css"><link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css"><link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css"><meta name="keywords" content="Southbound DB,OVS,OVN,OpenvSwitch"><link rel="alternate" href="/atom.xml" title="赵占旭的博客" type="application/atom+xml"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0"><meta name="description" content="Southbound DB主要是ovn-northd翻译Northbound DB产生的。然后由ovn-controller作为控制器，将SbDB翻译为真实的流表和ovs操作下发给OVS。"><meta name="keywords" content="Southbound DB,OVS,OVN,OpenvSwitch"><meta property="og:type" content="article"><meta property="og:title" content="OVN Southbound DB"><meta property="og:url" content="http://zhaozhanxu.com/2017/02/25/SDN/OVN/2017-02-25-ovn-sbdb/index.html"><meta property="og:site_name" content="赵占旭的博客"><meta property="og:description" content="Southbound DB主要是ovn-northd翻译Northbound DB产生的。然后由ovn-controller作为控制器，将SbDB翻译为真实的流表和ovs操作下发给OVS。"><meta property="og:locale" content="en"><meta property="og:image" content="http://zhaozhanxu.com/images/OVN/section2-1.bmp"><meta property="og:updated_time" content="2017-12-11T14:31:18.941Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="OVN Southbound DB"><meta name="twitter:description" content="Southbound DB主要是ovn-northd翻译Northbound DB产生的。然后由ovn-controller作为控制器，将SbDB翻译为真实的流表和ovs操作下发给OVS。"><meta name="twitter:image" content="http://zhaozhanxu.com/images/OVN/section2-1.bmp"><script type="text/javascript" id="hexo.configurations">var NexT=window.NexT||{},CONFIG={root:"/",sidebar:{position:"left",display:"post",offset:342,offset_float:0},fancybox:!0,motion:!0}</script><link rel="canonical" href="http://zhaozhanxu.com/2017/02/25/SDN/OVN/2017-02-25-ovn-sbdb/"><title> OVN Southbound DB | 赵占旭的博客</title></head><body itemscope itemtype="http://schema.org/WebPage" lang="en"><script>!function(e,a,t,c,n,g,o){e.GoogleAnalyticsObject="ga",e.ga=e.ga||function(){(e.ga.q=e.ga.q||[]).push(arguments)},e.ga.l=1*new Date,g=a.createElement("script"),o=a.getElementsByTagName("script")[0],g.async=1,g.src="//www.google-analytics.com/analytics.js",o.parentNode.insertBefore(g,o)}(window,document),ga("create","3a235f2280210fdd34cebc8c3647e5b8","auto"),ga("send","pageview")</script><script type="text/javascript">var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="//hm.baidu.com/hm.js?UA-90327054-1";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><script type="text/javascript">!function(){var e=document.createElement("script");e.src="//tajs.qq.com/stats?sId=60806179";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)}()</script><div class="container one-collumn sidebar-position-left page-post-detail"><div class="headband"></div><header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader" style="background-image:url(/images/public/home_bg.jpg)"><div class="header-cover"><div class="header-inner"><a class="site-home" href="/">赵占旭的博客</a><div class="site-meta"><div class="custom-logo-site-title"><div href="/" class="brand"><span class="logo-line-before"><i></i></span> <span class="site-title">赵占旭的博客</span><span class="logo-line-after"><i></i></span></div></div><h1 class="site-subtitle" itemprop="description">一花一世界 一叶一菩提</h1></div><div class="site-nav-toggle"> <button><span class="btn-bar"></span><span class="btn-bar"></span><span class="btn-bar"></span></button></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-categories"><a href="/categories" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i><br> Categories</a></li><li class="menu-item menu-item-tags"><a href="/tags" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i><br> Tags</a></li><li class="menu-item menu-item-archives"><a href="/archives" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i><br> Archives</a></li><li class="menu-item menu-item-about"><a href="/about" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i><br> About</a></li><li class="menu-item menu-item-search"><a href="javascript:" ; class="popup-trigger"><i class="menu-item-icon fa fa-search fa-fw"></i><br> Search</a></li></ul><div class="site-search"><div class="popup local-search-popup"><div class="local-search-header clearfix"><span class="search-icon"><i class="fa fa-search"></i></span><span class="popup-btn-close"><i class="fa fa-times-circle"></i></span><div class="local-search-input-wrapper"> <input autocapitalize="off" autocomplete="off" autocorrect="off" placeholder="search.placeholder" spellcheck="false" type="text" id="local-search-input"></div></div><div id="local-search-result"></div></div></div></nav></div><div class="header-post"><div class="post-header"><div class="tags"> <a href="/tags/OVS/" rel="tag" title="OVS">OVS</a> <a href="/tags/Network/" rel="tag" title="Network">Network</a> <a href="/tags/SDN/" rel="tag" title="SDN">SDN</a> <a href="/tags/OVN/" rel="tag" title="OVN">OVN</a></div><h1>OVN Southbound DB</h1><h2 class="subtitle">Section 3. SbDB存储的数据</h2><div class="post-time"> <span class="post-meta-item-text">Posted on</span> <time itemprop="dateCreated" datetime="2017-02-25T00:00:00+08:00" content="2017-02-25" title="2017-02-25 00:00:00">2017-02-25</time></div></div></div></div></header><main id="main" class="main"><div class="main-inner"><div class="content-wrap"><div id="content" class="content"><div id="posts" class="posts-expand"><article class="post post-type-normal" itemscope itemtype="http://schema.org/Article"><link itemprop="mainEntityOfPage" href="http://zhaozhanxu.com/2017/02/25/SDN/OVN/2017-02-25-ovn-sbdb/"><span style="display:none" itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="赵占旭"><meta itemprop="description" content=""><meta itemprop="image" content="/images/public/me.jpg"></span><span style="display:none" itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="赵占旭的博客"> <span style="display:none" itemprop="logo" itemscope itemtype="http://schema.org/ImageObject"><img style="display:none" itemprop="url image" alt="赵占旭的博客" src=""></span></span><div class="post-inner"><header class="post-header"><h2 class="post-title" itemprop="name headline"> OVN Southbound DB</h2><div class="post-meta"><span class="post-time"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i></span> <span class="post-meta-item-text">Posted on</span> <time title="Post created" itemprop="dateCreated datePublished" datetime="2017-02-25T00:00:00+08:00">2017-02-25</time></span></div></header><div class="post-info"><div class="post-categories"> <a class="color" href="/categories/OVN/" rel="tag">OVN</a></div><div class="post-tags"> <a class="color" href="/tags/OVS/" rel="tag">OVS</a> <a class="color" href="/tags/Network/" rel="tag">Network</a> <a class="color" href="/tags/SDN/" rel="tag">SDN</a> <a class="color" href="/tags/OVN/" rel="tag">OVN</a></div><div class="clearfix"></div></div><div class="post-body" itemprop="articleBody"><p>Southbound DB主要是ovn-northd翻译Northbound DB产生的。然后由ovn-controller作为控制器，将SbDB翻译为真实的流表和ovs操作下发给OVS。</p><a id="more"></a><h1 id="拓扑"><a href="#拓扑" class="headerlink" title="拓扑"></a>拓扑</h1><hr><p>前面介绍了我们查看数据库的拓扑，这里再贴一下:</p><p><img src="/images/OVN/section2-1.bmp" alt="avatar"></p><h1 id="Southbound-DB"><a href="#Southbound-DB" class="headerlink" title="Southbound DB"></a>Southbound DB</h1><hr><h2 id="内容展示"><a href="#内容展示" class="headerlink" title="内容展示"></a>内容展示</h2><p>Southbound DB位于控制节点，主要是由ovn-northd服务将Northbound DB中的数据翻译之后的信息，就不像之前有那么好的可读性了，但是相对OVS展现的信息还是具有一定的可读性，相当于逻辑拓扑和底层的实际流表的一个中间状态，接下来我们就看一下它包含了哪些信息，详细信息可以查看可以查看文件ovn-sb.ovsschema，或者<a href="http://openvswitch.org/support/dist-docs/ovn-sb.5.txt" target="_blank" rel="noopener">ovn-sb.5.txt</a>:</p><ul><li>SB_Global 存储一些全局信息</li><li>Chassis表示一个hypervisor或者网关或者物理网络<ul><li>name 通过external_ids:system-id添加</li><li>hostname代表物理机Host</li><li>nb_cfg从上面SB_Global拷贝的</li><li>external_ids: ovn-bridge-mappings 映射桥和物理网络，比如physnet1:br-eth0</li><li>external_ids: datapath-type 配置类型，默认是system，但是我们需要DPDK的时候需要配置为netdev</li><li>external_ids: iface-types 配置端口类型</li><li>encaps 表示配置的tunnel类型</li></ul></li><li>Encap表示tunnel封装的配置<ul><li>type 封装的类型</li><li>options可以包含一些其他的信息</li><li>ip表示我们封装tunnel的源ip</li></ul></li><li>Address_set 可以查看NbDB的信息</li><li>Logical Flow表示了逻辑流表<ul><li>logical_datapath Datapath_Binding 表示Logical Flow属于哪个datapath</li><li>pipeline ingress或者egress，一般是ingress直接对接egress</li><li>table_id 0-15 类似Openflow的table id，但是更少</li><li>priority 0-65535 和Openflows的优先级，越大越高</li><li>match 匹配项，更加通俗易懂一些</li><li>actions 更加易懂</li></ul></li><li>Multicast_Group<ul><li>datapath: Datapath_Binding</li><li>tunnel_key</li><li>name</li><li>ports</li></ul></li><li>Datapath_Binding 每个Logical datapath实现了Port_Binding中的端口的Logical pipeline<ul><li>tunnel_key 1-16777215 每个Logical datapath绑定一个</li><li>external_ids: logical-switch 一个Logical datapath代表了一个logical switch</li><li>external_ids: logical-router 一个Logical datapath代表了一个logical router</li><li>external_ids: name ovn-northd从NbDB中的Logical switch或者Logical router拷贝过来UUID</li></ul></li><li>Port_Binding<ul><li>datapath Logical port所属的Logical datapath</li><li>logical_port 从NbDB中Logical_Switch_Port获取的</li><li>chassis<ul><li>默认 Logical port</li><li>vtep hardware_vtep gateway</li><li>localnet</li><li>l3gateway</li><li>l2gateway</li></ul></li><li>tunnel_key 1-32767 Logical Port记录的key值</li><li>mac Logical Port的mac</li><li>type 端口类型<ul><li>默认 VM端口</li><li>patch</li><li>l3gateway 连接多个chassis</li><li>localnet</li><li>l2gateway</li><li>vtep</li><li>chassisredirect 重定向到其他的chassis</li></ul></li><li>patch 选项<ul><li>peer</li></ul></li><li>L3网关选项<ul><li>peer</li><li>l3gateway-chassis</li><li>nat-address</li></ul></li><li>Localnet选项<ul><li>network_name</li></ul></li><li>L2 网关选项<ul><li>network_name</li><li>l2gateway-chassis</li></ul></li><li>VTEP选项<ul><li>vtep-physical-switch</li><li>vtep-logical-switch</li></ul></li><li>VMI选项<ul><li>qos_max_rate</li><li>qos_burst</li><li>qdisc_queue_id</li></ul></li><li>Chassis Redirect选项<ul><li>distributed-port</li><li>redirect-chassis</li></ul></li><li>Nested Containers<ul><li>parent_port</li><li>tag</li></ul></li></ul></li><li>MAC_Binding logical_port和IP得到MAC<ul><li>logical_port, ip, mac, datapath</li></ul></li><li>DHCP_Options 包含name, code, type</li><li>DHCPv6_Options</li><li>Connection</li><li>SSL</li></ul><h2 id="chassis信息展示"><a href="#chassis信息展示" class="headerlink" title="chassis信息展示"></a>chassis信息展示</h2><p><code>ovn-sbctl show</code>展示的是chassis信息，每项的意义上面已经介绍。</p><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">//此处的chassis的名字对应的是ovs的system-id，通过命令ovs-vsctl get open . external-ids:system-id查看</span><br><span class="line">//相当于每个宿主机的ovn-controller根据这个id来确定自己属于哪个chassis</span><br><span class="line">Chassis "0d8eee77-63c1-4250-a9f0-c242360525d5"</span><br><span class="line">    //设备的主机名</span><br><span class="line">    hostname: "compute1"</span><br><span class="line">    //封装类型</span><br><span class="line">    Encap geneve</span><br><span class="line">        //封装的Local IP</span><br><span class="line">        ip: "1.1.1.201"</span><br><span class="line">        //options</span><br><span class="line">        options: &#123;csum="true"&#125;</span><br><span class="line">    //绑定的端口</span><br><span class="line">    Port_Binding "ls1-vm1"</span><br><span class="line">    Port_Binding "ls2-vm3"</span><br><span class="line">Chassis "e748fbdb-60bc-4707-87e6-66823a343990"</span><br><span class="line">    hostname: "compute2"</span><br><span class="line">    Encap geneve</span><br><span class="line">        ip: "1.1.1.202"</span><br><span class="line">        options: &#123;csum="true"&#125;</span><br><span class="line">    Port_Binding "ls1-vm2"</span><br><span class="line">    Port_Binding "ls2-vm4"</span><br><span class="line">Chassis "5fa32c09-4b0c-4f35-bdfc-9a6675bf1b95"</span><br><span class="line">    hostname: "network"</span><br><span class="line">    Encap geneve</span><br><span class="line">        ip: "1.1.1.200"</span><br><span class="line">        options: &#123;csum="true"&#125;</span><br></pre></td></tr></table></figure><h2 id="Logical-Flow信息展示"><a href="#Logical-Flow信息展示" class="headerlink" title="Logical Flow信息展示"></a>Logical Flow信息展示</h2><p><code>ovn-sbctl dump-flows</code>展示的是流表，下面会展示，所以我们在这里仅仅介绍一下Logical Flow的pipeline。详细文档可以参照<a href="http://openvswitch.org/support/dist-docs/ovn-northd.8.txt" target="_blank" rel="noopener">ovn-northd</a></p><h3 id="LS-ingress流表展示"><a href="#LS-ingress流表展示" class="headerlink" title="LS ingress流表展示"></a>LS ingress流表展示</h3><ul><li>table=0 ls_in_port_sec_l2 L2的端口安全<ul><li>100优先级的丢弃带有VLAN标签或者源MAC多播的报文</li><li>50优先级，port security开启的话，匹配inport、合理eth.src的报文给到下一级，不开启的话将所有的报文给到下一级</li><li>没流表了，但是默认就是丢包</li></ul></li><li>table=1 ls_in_port_sec_ip IP的端口安全<ul><li>90优先级允许匹配inport、合理的eth.src和ip4.src通过</li><li>90优先级允许合理的eth.src的IPv4的DHCP discovery流量通过，因为IP没有被分配的时候为0.0.0.0</li><li>ipv6同上两条，优先级一致，这个下面默认不说就是优先级一致</li><li>80优先级允许丢弃匹配in_port、合理eth.src的IPv4和IPv6流量</li><li>0匹配所有的报文，给到下一级table，此表以下都有就不写了</li></ul></li><li>table=2 ls_in_port_sec_nd 邻居发现的端口安全<ul><li>90优先级的流表允许匹配in_port、合理eth.src和arp.sha的报文通过</li><li>ipv6同上</li><li>80优先级丢弃匹配in_port和合理eth.src的ARP或者IPv6的发现报文</li></ul></li><li>table=3 ls_in_pre_acl from-lport Pre-Acls<ul><li>如果设置了ACL，100优先级设置reg0[0] = 1；next为了发给conntrack加状态做准备</li></ul></li><li>table=4 ls_in_pre_lb<ul><li>如果配置了LB，100优先级为每个VIP添加一个match(ip &amp;&amp; ip4.dst==VIP)并且设置action=(reg0[0] = 1; next)</li></ul></li><li>table=5 ls_in_pre_stateful<ul><li>100优先级将reg0[0] == 1的报文使用action=(ct_next;)发送给conntrack</li></ul></li><li>table=6 ls_in_acl from-lport ACLS<ul><li>65535优先级允许回复方向的报文转发到下一级，即action=(next;)，这个是allow ACLs翻译的</li><li>65535优先级允许已经commit的报文转发到下一级</li><li>65535优先级丢弃所有ct.inv的报文</li><li>65535优先级丢弃所有ct_label.blocked==1的报文</li><li>1优先级将不是establish的报文翻译为action=(reg0[1] = 1; next;)，这个是allow-related翻译的</li></ul></li><li>table=7 ls_in_qos from-lport QoS marking<ul><li>需要添加的QoS</li></ul></li><li>table=8 ls_in_lb LB<ul><li>100优先级match(ct.est &amp;&amp; !ct.rel &amp;&amp; !ct.new &amp;&amp; !ct.inv)执行action=(reg0[2] = 1; next;)意味着通过conntrack发送报文到NAT模块</li></ul></li><li>table=9 ls_in_stateful<ul><li>120优先级协议P、IP地址VIP和端口PORT，match(ct.new &amp;&amp; ip &amp;&amp; ip4.dst == VIP &amp;&amp; P &amp;&amp; P.dst == PORT)，action=(ct_lb(args))表示LB到哪个args IP。</li><li>110优先级匹配IP地址，match(ct.new &amp;&amp; ip &amp;&amp; ip4.dst == VIP)，action=(ct_lb(args))</li><li>100优先级match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)</li><li>100优先级match=(reg0[2] == 1), action=(ct_lb;)</li></ul></li><li>table=10 ls_in_arp_rsp arp请求<ul><li>100优先级将inport类型为localnet和vtep的arp请求直接转发到下一级的流表</li><li>100优先级和下面比，match项多了一项inport，就是检查自己端口发出的报文，请求是自己IP的ARP请求，就会转发到下一级，这么做是为了检查网段内有没有IP冲突</li><li>50优先级将Logical带有的IP进行ARP请求的IP作为匹配，并且修改报文的ARP项中的源目的IP和MAC，设置loopback标志发送，这里有多少Logical Port IP就有多少条</li><li>IPv6同上</li></ul></li><li>table=11 ls_in_dhcp_options DHCP options处理<ul><li>100优先级根据源端口、源IP、inport、UDP源端口68和目的端口67判定是否符合条件的DHCP请求，将需要给的IP等一系列信息通过put_dhcp_opts传递给reg0[3]，转发下一级流表，也可以多条</li><li>IPv6同上</li></ul></li><li>table=12 ls_in_dhcp_response<ul><li>100优先级主要是将前面符合DHCP请求报文进行修改，修改为回复报文，类似ARP回复，设置loopback标志发送，也是多条</li><li>DHCPv6同上</li></ul></li><li>table=13 ls_in_l2_lkup<ul><li>100优先级将广播报文直接，出端口设置为MC_FLOOD发送</li><li>50优先级将Logical Port支持的MAC进行匹配目的MAC，出端口设置为该Logical Port发送，多条</li></ul></li></ul><h3 id="LS-egress流表展示"><a href="#LS-egress流表展示" class="headerlink" title="LS egress流表展示"></a>LS egress流表展示</h3><ul><li>table=0 ls_out_pre_lb 类似上面ls_in_pre_lb</li><li>table=1 ls_out_pre_acl 类似上面ls_in_pre_acl，只不过这里是to-lport</li><li>table=2 ls_out_pre_stateful 类似上面ls_in_pre_stateful</li><li>table=3 ls_out_lb 类似上面的ls_in_lb</li><li>table=4 ls_out_acl 类似上面的ls_in_acl，这里也是to-lport</li><li>table=5 ls_out_qos 类似上面的ls_in_qos，也是to-lport</li><li>table=6 ls_out_stateful 和上面的ls_in_stateful类似，没有LB相关的操作<ul><li>34000优先级允许ls_in_dhcp_response回复的报文通过</li></ul></li><li>table=7 ls_out_port_sec_ip 和上面的ls_in_port_sec_ip类似，只是inport、eth.src、ip4.src、ip6.src更换成了outport和目的地址</li><li>table=8 ls_out_port_sec_l2 类似ls_in_port_sec_l2，出入端口和源目的地址要替换<ul><li>150优先级将disabled Logical Port的广播、多播报文丢弃</li><li>100优先级允许广播、多播的通过</li></ul></li></ul><h3 id="LR-ingress流表展示"><a href="#LR-ingress流表展示" class="headerlink" title="LR ingress流表展示"></a>LR ingress流表展示</h3><ul><li>table=0 lr_in_admission<ul><li>100优先级丢掉带有vlan标签或者源MAC多播的报文</li><li>50优先级满足入端口和目的MAC一致或者多播的时候转发下一级</li><li>50优先级入端口是GW，匹配扩展目的MAC的时候转发下一级，主要用于分布式路由并且有NAT规则时</li><li>没流表了，但是默认就是丢包</li></ul></li><li>table=1 lr_in_ip_input<ul><li>100优先级满足以下条件之一的会丢掉<ul><li>源IP多播</li><li>源IP广播</li><li>localhost的源目的IP</li><li>zero network的源目的IP</li><li>源IP是Router拥有的IP，一般是网关IP并且reg9[1] == 0，这个应该是指定不是loopback的报文</li><li>router已知任意IP的广播地址，什么鬼。。。</li></ul></li><li>90优先级，做IPv4和IPv6的网关IP的ICMP echo reply</li><li>90优先级，做IPv4和IPv6的网关IP的邻居子系统的回复，arp和nd</li><li>和上面一条类似，但是是给NAT和LB的虚拟IP的代答</li><li>90优先级处理arp reply，维护arp表</li><li>80优先级处理UDP端口不可达，Logical Router不接受UDP报文</li><li>80优先级处理TCP reset，Logical Router不接受TCP报文</li><li>70优先级处理协议不可达，支持TCP、UDP和ICMP</li><li>60优先级丢弃目的IP为Router网关的报文</li><li>50优先级丢弃Ethernet local broadcast的报文</li><li>40优先级将inport是Router端口的TTL到期的报文回复ICMP的超时回复报文</li><li>30优先级丢弃TTL到期的报文</li><li>0匹配所有的报文，给到下一级table，此表以下都有就不写了</li></ul></li><li>table=2 lr_in_defrag<ul><li>100优先级匹配IP报文，并且目的IP是LB指定VIP的时候，执行ct_next去conntrack报道，为LB存在</li></ul></li><li>table=3 lr_in_unsnat<ul><li>网关Router<ul><li>110优先级强制SNAT之前DNAT过的报文到B，匹配目的IP为B执行ct_snat;next;</li><li>100优先级强制SNAT之前LB过的报文到B，同上</li><li>90优先级修改源IP A到B的报文，同上</li></ul></li><li>分布式Router 这块可以再细看看<ul><li>100优先级修改源IP A到B的报文，匹配目的IP为B，并且inport==GW的报文，执行ct_snat;next;</li><li>50优先级同上，只是最终执行变成了REGBIT_NAT_REDIRECT = 1; next;貌似是其他路由端口上收上来的报文需要重定向到分布式网关端口来进行NAT操作</li></ul></li></ul></li><li>table=4 lr_in_dnat<ul><li>网关Router<ul><li>120优先级match(ct.new &amp;&amp; ip &amp;&amp; ip4.dst == VIP &amp;&amp; P &amp;&amp; P.dst == PORT), action=(flags.force_snat_for_lb = 1; ct_lb(args);)</li><li>120优先级match(ct.est &amp;&amp; ip &amp;&amp; ip4.dst == VIP &amp;&amp; P &amp;&amp; P.dst == PORT), action=(flags.force_snat_for_lb = 1; ct_dnat;)</li><li>110优先级match(ct.new &amp;&amp; ip &amp;&amp; ip4.dst == VIP), action=(flags.force_nat_for_lb = 1; ct_lb(args);)</li><li>110优先级match(ct.est &amp;&amp; ip &amp;&amp; ip4.dst == VIP), action=(flags.force_snat_for_lb = 1; ct_dnat;)</li><li>100优先级把A目的IP修改B，match(ip &amp;&amp; ip4.dst == A), action=(flags.force_snat_for_lb = 1; flags.loopback = 1; ct_dnat(B));</li><li>50优先级所有的网关Router的IP都执行操作action=(flags.loopback=1; ct_dnat;)</li></ul></li><li>分布式Router<ul><li>100优先级把A目的IP修改为B，match(ip &amp;&amp; ip4.dst == B &amp;&amp; inport == GW), action=(ct_dnat(B);)</li><li>50优先级把A目的IP修改为B，match(ip &amp;&amp; ip4.dst == B), action=(REGBIT_NAT_REDIRECT = 1; next;)</li></ul></li></ul></li><li>table=5 lr_in_ip_routing<ul><li>300优先级match(REGBIT_NAT_REDIRECT == 1), action=(ip.ttl–; next;)</li><li>文档没说优先级，我看到的是IPv6是129优先级，IPv4是49优先级，分别根据目的IP段进行匹配，执行操作有ttl减一、记录网关IP、记录目的IP、源MAC修改、出端口指定等操作，最后转发下一级流表</li><li>这里是上面的例子match=(ip4.dst == 192.168.1.0/24), action=(ip.ttl–; reg0 = ip4.dst; reg1 = 192.168.1.1; eth.src = 52:54:00:c1:68:50; outport = “lr1-ls1”; flags.loopback = 1; next;)</li></ul></li><li>table=6 lr_in_arp_resolve<ul><li>200优先级match(REGBIT_NAT_REDIRECT == 1), action=(eth.dst = E; next;)</li><li>100优先级是静态的MAC绑定，IPv4和IPv6的报文匹配端口为Router Port和reg0为已知的段内IP，执行操作修改目的MAC为IP的MAC转发</li><li>0优先级是动态的MAC绑定，IPv4和IPv6的报文匹配IP报文即可，执行的操作为action=(get_arp(outport, reg0); next;)或者action=(get_nd(outport, xxreg0); next;)</li></ul></li><li>table=7 lr_in_gw_redirect<ul><li>200优先级match(REGBIT_NAT_REDIRECT == 1), action=(outport=CR; next;)</li><li>150优先级match(output == GW &amp;&amp; eth.dst == 00:00:00:00:00:00), action=(outport=CR; next;)</li><li>100优先级有NAT规则的时候match(ip4.src == B &amp;&amp; outport == GW), action=(next;)</li><li>50优先级match(outport == GW), action=(outport=CR; next;)</li></ul></li><li>table=8 lr_in_arp_request<ul><li>100优先级目的MAC为0的时候，封装ARP Request报文，主要是目的MAC修改为广播、源IP从reg1取，目标IP从reg0取、操作为request，最后发送</li></ul></li></ul><h3 id="LR-egress流表展示"><a href="#LR-egress流表展示" class="headerlink" title="LR egress流表展示"></a>LR egress流表展示</h3><ul><li>table=0 lr_out_undnat<ul><li>100优先级match(ip &amp;&amp; ip4.src == B &amp;&amp; outport == GW), action=(ct_dnat;)</li></ul></li><li>table=1 lr_out_snat<ul><li>网关Router<ul><li>100优先级强制SNAT之前DNAT过的报文为B，match(flags.force_snat_for_dnat == 1 &amp;&amp; ip), action=(ct_snat(B);)</li><li>100优先级强制SNAT之前LB过得报文为B，match(flags.force_snat_fir_lb == 1 &amp;&amp; ip), action=(ct_snat(b);)</li><li>优先级不固定，SNAT a==&gt;B，由A计算优先级，match(ip &amp;&amp; ip4.src == A), action=(ct_snat(B));</li></ul></li><li>分布式Router<ul><li>优先级不固定，SNAT a==&gt;B，由A计算优先级，match(ip &amp;&amp; ip4.src == A &amp;&amp; outport == GW), action=(ct_snat(B));</li></ul></li></ul></li><li>table=2 lr_out_egr_loop<ul><li>100优先级支持NAT规则时使用，将目的IP是NAT指定的IP而出端口是GW端口的话，报文回注到ingress的table 0</li></ul></li><li>table=3 lr_out_delivery<ul><li>100优先级的出口匹配Logical Router Port，执行发送操作</li></ul></li></ul><h3 id="逻辑流表展示"><a href="#逻辑流表展示" class="headerlink" title="逻辑流表展示"></a>逻辑流表展示</h3><p>首先查看逻辑路由的逻辑流表</p><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line">Datapath: "lr1" (f93e843a-0b9c-4c50-8ef2-d3a338661759)  Pipeline: ingress</span><br><span class="line"></span><br><span class="line">//table 0 比较简单，就是说允许从逻辑交换机来的报文，到网关或者广播的都允许通过</span><br><span class="line">table=0 (lr_in_admission    ), priority=100  , match=(vlan.present || eth.src[40]), action=(drop;)</span><br><span class="line">table=0 (lr_in_admission    ), priority=50   , match=(eth.dst == 52:54:00:c1:68:50 &amp;&amp; inport == "lr1-ls1"), action=(next;)</span><br><span class="line">table=0 (lr_in_admission    ), priority=50   , match=(eth.dst == 52:54:00:c1:68:60 &amp;&amp; inport == "lr1-ls2"), action=(next;)</span><br><span class="line">table=0 (lr_in_admission    ), priority=50   , match=(eth.mcast &amp;&amp; inport == "lr1-ls1"), action=(next;)</span><br><span class="line">table=0 (lr_in_admission    ), priority=50   , match=(eth.mcast &amp;&amp; inport == "lr1-ls2"), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 1 首先丢掉一些不符合条件的报文，不关心，接下来就是网关arp和icmp的代答</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=100  , match=(ip4.mcast || ip4.src == 255.255.255.255 || ip4.src == 127.0.0.0/8 || ip4.dst == 127.0.0.0/8 || ip4.src == 0.0.0.0/8 || ip4.dst == 0.0.0.0/8), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=100  , match=(ip4.src == &#123;192.168.1.1, 192.168.1.255&#125; &amp;&amp; reg9[1] == 0), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=100  , match=(ip4.src == &#123;192.168.2.1, 192.168.2.255&#125; &amp;&amp; reg9[1] == 0), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=100  , match=(ip6.src == fe80::5054:ff:fec1:6850), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=100  , match=(ip6.src == fe80::5054:ff:fec1:6860), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(arp.op == 2), action=(put_arp(inport, arp.spa, arp.sha);)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(inport == "lr1-ls1" &amp;&amp; arp.tpa == 192.168.1.1 &amp;&amp; arp.op == 1), action=(eth.dst = eth.src; eth.src = 52:54:00:c1:68:50; arp.op = 2; /* ARP reply */ arp.tha = arp.sha; arp.sha = 52:54:00:c1:68:50; arp.tpa = arp.spa; arp.spa = 192.168.1.1; outport = "lr1-ls1"; flags.loopback = 1; output;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(inport == "lr1-ls1" &amp;&amp; nd_ns &amp;&amp; ip6.dst == &#123;fe80::5054:ff:fec1:6850, ff02::1:ffc1:6850&#125; &amp;&amp; nd.target == fe80::5054:ff:fec1:6850), action=(put_nd(inport, ip6.src, nd.sll); nd_na &#123; eth.src = 52:54:00:c1:68:50; ip6.src = fe80::5054:ff:fec1:6850; nd.target = fe80::5054:ff:fec1:6850; nd.tll = 52:54:00:c1:68:50; outport = inport; flags.loopback = 1; output; &#125;;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(inport == "lr1-ls2" &amp;&amp; arp.tpa == 192.168.2.1 &amp;&amp; arp.op == 1), action=(eth.dst = eth.src; eth.src = 52:54:00:c1:68:60; arp.op = 2; /* ARP reply */ arp.tha = arp.sha; arp.sha = 52:54:00:c1:68:60; arp.tpa = arp.spa; arp.spa = 192.168.2.1; outport = "lr1-ls2"; flags.loopback = 1; output;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(inport == "lr1-ls2" &amp;&amp; nd_ns &amp;&amp; ip6.dst == &#123;fe80::5054:ff:fec1:6860, ff02::1:ffc1:6860&#125; &amp;&amp; nd.target == fe80::5054:ff:fec1:6860), action=(put_nd(inport, ip6.src, nd.sll); nd_na &#123; eth.src = 52:54:00:c1:68:60; ip6.src = fe80::5054:ff:fec1:6860; nd.target = fe80::5054:ff:fec1:6860; nd.tll = 52:54:00:c1:68:60; outport = inport; flags.loopback = 1; output; &#125;;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(ip4.dst == 192.168.1.1 &amp;&amp; icmp4.type == 8 &amp;&amp; icmp4.code == 0), action=(ip4.dst <span class="tag">&lt;<span class="name">-</span>&gt;</span> ip4.src; ip.ttl = 255; icmp4.type = 0; flags.loopback = 1; next; )</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(ip4.dst == 192.168.2.1 &amp;&amp; icmp4.type == 8 &amp;&amp; icmp4.code == 0), action=(ip4.dst <span class="tag">&lt;<span class="name">-</span>&gt;</span> ip4.src; ip.ttl = 255; icmp4.type = 0; flags.loopback = 1; next; )</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(ip6.dst == fe80::5054:ff:fec1:6850 &amp;&amp; icmp6.type == 128 &amp;&amp; icmp6.code == 0), action=(ip6.dst <span class="tag">&lt;<span class="name">-</span>&gt;</span> ip6.src; ip.ttl = 255; icmp6.type = 129; flags.loopback = 1; next; )</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(ip6.dst == fe80::5054:ff:fec1:6860 &amp;&amp; icmp6.type == 128 &amp;&amp; icmp6.code == 0), action=(ip6.dst <span class="tag">&lt;<span class="name">-</span>&gt;</span> ip6.src; ip.ttl = 255; icmp6.type = 129; flags.loopback = 1; next; )</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=90   , match=(nd_na), action=(put_nd(inport, nd.target, nd.tll);)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=80   , match=(nd_ns), action=(put_nd(inport, ip6.src, nd.sll);)</span><br><span class="line"></span><br><span class="line">//table 1 的网关不可连接，所以到网关的报文除了之前的处理都丢掉，其他的报文直接通过</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=60   , match=(ip4.dst == &#123;192.168.1.1&#125;), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=60   , match=(ip4.dst == &#123;192.168.2.1&#125;), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=60   , match=(ip6.dst == fe80::5054:ff:fec1:6850), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=60   , match=(ip6.dst == fe80::5054:ff:fec1:6860), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=50   , match=(eth.bcast), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=30   , match=(ip4 &amp;&amp; ip.ttl == &#123;0, 1&#125;), action=(drop;)</span><br><span class="line">table=1 (lr_in_ip_input     ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 2 3 4 因为我们没有配置，所以没有相关的操作</span><br><span class="line">table=2 (lr_in_defrag       ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=3 (lr_in_unsnat       ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=4 (lr_in_dnat         ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 5 直接转发，根据目的IP进行转发</span><br><span class="line">table=5 (lr_in_ip_routing   ), priority=129  , match=(inport == "lr1-ls1" &amp;&amp; ip6.dst == fe80::/64), action=(ip.ttl--; xxreg0 = ip6.dst; xxreg1 = fe80::5054:ff:fec1:6850; eth.src = 52:54:00:c1:68:50; outport = "lr1-ls1"; flags.loopback = 1; next;)</span><br><span class="line">table=5 (lr_in_ip_routing   ), priority=129  , match=(inport == "lr1-ls2" &amp;&amp; ip6.dst == fe80::/64), action=(ip.ttl--; xxreg0 = ip6.dst; xxreg1 = fe80::5054:ff:fec1:6860; eth.src = 52:54:00:c1:68:60; outport = "lr1-ls2"; flags.loopback = 1; next;)</span><br><span class="line">table=5 (lr_in_ip_routing   ), priority=49   , match=(ip4.dst == 192.168.1.0/24), action=(ip.ttl--; reg0 = ip4.dst; reg1 = 192.168.1.1; eth.src = 52:54:00:c1:68:50; outport = "lr1-ls1"; flags.loopback = 1; next;)</span><br><span class="line">table=5 (lr_in_ip_routing   ), priority=49   , match=(ip4.dst == 192.168.2.0/24), action=(ip.ttl--; reg0 = ip4.dst; reg1 = 192.168.2.1; eth.src = 52:54:00:c1:68:60; outport = "lr1-ls2"; flags.loopback = 1; next;)</span><br><span class="line"></span><br><span class="line">//table 6 根据出端口和上面reg0拿到的目的IP获取arp信息，得到相应的IP对应的mac</span><br><span class="line">table=6 (lr_in_arp_resolve  ), priority=0    , match=(ip4), action=(get_arp(outport, reg0); next;)</span><br><span class="line">table=6 (lr_in_arp_resolve  ), priority=0    , match=(ip6), action=(get_nd(outport, xxreg0); next;)</span><br><span class="line"></span><br><span class="line">//table 7 不清楚</span><br><span class="line">table=7 (lr_in_gw_redirect  ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 8 表示前面要么没有获取相应的arp信息，就发arp request，要么就直接转发</span><br><span class="line">table=8 (lr_in_arp_request  ), priority=100  , match=(eth.dst == 00:00:00:00:00:00), action=(arp &#123; eth.dst = ff:ff:ff:ff:ff:ff; arp.spa = reg1; arp.tpa = reg0; arp.op = 1; output; &#125;;)</span><br><span class="line">table=8 (lr_in_arp_request  ), priority=0    , match=(1), action=(output;)</span><br><span class="line"></span><br><span class="line">Datapath: "lr1" (f93e843a-0b9c-4c50-8ef2-d3a338661759)  Pipeline: egress</span><br><span class="line"></span><br><span class="line">//table 0 1 2 都不管</span><br><span class="line">table=0 (lr_out_undnat      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=1 (lr_out_snat        ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=2 (lr_out_egr_loop    ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 3 表示根据出口直接发送</span><br><span class="line">table=3 (lr_out_delivery    ), priority=100  , match=(outport == "lr1-ls1"), action=(output;)</span><br><span class="line">table=3 (lr_out_delivery    ), priority=100  , match=(outport == "lr1-ls2"), action=(output;)</span><br></pre></td></tr></table></figure><p>接下来查看逻辑交换机1的逻辑流表</p><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line">Datapath: "ls1" (94b0f9b2-a91e-435b-8db2-01dec1acbf3d)  Pipeline: ingress</span><br><span class="line"></span><br><span class="line">//table 0 表示来自逻辑路由和来自虚拟机的报文都可以通过，前提是mac是对的</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=100  , match=(eth.src[40]), action=(drop;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=100  , match=(vlan.present), action=(drop;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=50   , match=(inport == "ls1-lr1"), action=(next;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=50   , match=(inport == "ls1-vm1" &amp;&amp; eth.src == &#123;52:54:00:c1:68:70&#125;), action=(next;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=50   , match=(inport == "ls1-vm2" &amp;&amp; eth.src == &#123;52:54:00:c1:68:72&#125;), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 1 没有啥安全设置</span><br><span class="line">table=1 (ls_in_port_sec_ip  ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 2 是vm的arp安全检测</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls1-vm1" &amp;&amp; eth.src == 52:54:00:c1:68:70 &amp;&amp; arp.sha == 52:54:00:c1:68:70), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls1-vm1" &amp;&amp; eth.src == 52:54:00:c1:68:70 &amp;&amp; ip6 &amp;&amp; nd &amp;&amp; ((nd.sll == 00:00:00:00:00:00 || nd.sll == 52:54:00:c1:68:70) || ((nd.tll == 00:00:00:00:00:00 || nd.tll == 52:54:00:c1:68:70)))), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls1-vm2" &amp;&amp; eth.src == 52:54:00:c1:68:72 &amp;&amp; arp.sha == 52:54:00:c1:68:72), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls1-vm2" &amp;&amp; eth.src == 52:54:00:c1:68:72 &amp;&amp; ip6 &amp;&amp; nd &amp;&amp; ((nd.sll == 00:00:00:00:00:00 || nd.sll == 52:54:00:c1:68:72) || ((nd.tll == 00:00:00:00:00:00 || nd.tll == 52:54:00:c1:68:72)))), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=80   , match=(inport == "ls1-vm1" &amp;&amp; (arp || nd)), action=(drop;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=80   , match=(inport == "ls1-vm2" &amp;&amp; (arp || nd)), action=(drop;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 3 - 12 没有啥设置，都是过</span><br><span class="line">table=3 (ls_in_pre_acl      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=4 (ls_in_pre_lb       ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=5 (ls_in_pre_stateful ), priority=100  , match=(reg0[0] == 1), action=(ct_next;)</span><br><span class="line">table=5 (ls_in_pre_stateful ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=6 (ls_in_acl          ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=7 (ls_in_qos_mark     ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=8 (ls_in_lb           ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=9 (ls_in_stateful     ), priority=100  , match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)</span><br><span class="line">table=9 (ls_in_stateful     ), priority=100  , match=(reg0[2] == 1), action=(ct_lb;)</span><br><span class="line">table=9 (ls_in_stateful     ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=10(ls_in_arp_rsp      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=11(ls_in_dhcp_options ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=12(ls_in_dhcp_response), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 13 会根据mac地址查找该发到哪里</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=100  , match=(eth.mcast), action=(outport = "_MC_flood"; output;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=50   , match=(eth.dst == 52:54:00:c1:68:50), action=(outport = "ls1-lr1"; output;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=50   , match=(eth.dst == 52:54:00:c1:68:70), action=(outport = "ls1-vm1"; output;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=50   , match=(eth.dst == 52:54:00:c1:68:72), action=(outport = "ls1-vm2"; output;)</span><br><span class="line"></span><br><span class="line">Datapath: "ls1" (94b0f9b2-a91e-435b-8db2-01dec1acbf3d)  Pipeline: egress</span><br><span class="line"></span><br><span class="line">//table 0 - 7 都没啥设置</span><br><span class="line">table=0 (ls_out_pre_lb      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=1 (ls_out_pre_acl     ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=2 (ls_out_pre_stateful), priority=100  , match=(reg0[0] == 1), action=(ct_next;)</span><br><span class="line">table=2 (ls_out_pre_stateful), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=3 (ls_out_lb          ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=4 (ls_out_acl         ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=5 (ls_out_qos_mark    ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=6 (ls_out_stateful    ), priority=100  , match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)</span><br><span class="line">table=6 (ls_out_stateful    ), priority=100  , match=(reg0[2] == 1), action=(ct_lb;)</span><br><span class="line">table=6 (ls_out_stateful    ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=7 (ls_out_port_sec_ip ), priority=0    , match=(1), action=(next;)</span><br><span class="line"></span><br><span class="line">//table 8 主要是根据mac进行发送了</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=100  , match=(eth.mcast), action=(output;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=50   , match=(outport == "ls1-lr1"), action=(output;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=50   , match=(outport == "ls1-vm1" &amp;&amp; eth.dst == &#123;52:54:00:c1:68:70&#125;), action=(output;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=50   , match=(outport == "ls1-vm2" &amp;&amp; eth.dst == &#123;52:54:00:c1:68:72&#125;), action=(output;)</span><br></pre></td></tr></table></figure><p>最后查看逻辑交换机2的逻辑流表，和以上类似，这里不做标注</p><figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line">Datapath: "ls2" (85cd1eaf-5f4c-45e2-882b-11d0f96aba9e)  Pipeline: ingress</span><br><span class="line"></span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=100  , match=(eth.src[40]), action=(drop;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=100  , match=(vlan.present), action=(drop;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=50   , match=(inport == "ls2-lr1"), action=(next;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=50   , match=(inport == "ls2-vm3" &amp;&amp; eth.src == &#123;52:54:00:c1:68:71&#125;), action=(next;)</span><br><span class="line">table=0 (ls_in_port_sec_l2  ), priority=50   , match=(inport == "ls2-vm4" &amp;&amp; eth.src == &#123;52:54:00:c1:68:73&#125;), action=(next;)</span><br><span class="line">table=1 (ls_in_port_sec_ip  ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls2-vm3" &amp;&amp; eth.src == 52:54:00:c1:68:71 &amp;&amp; arp.sha == 52:54:00:c1:68:71), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls2-vm3" &amp;&amp; eth.src == 52:54:00:c1:68:71 &amp;&amp; ip6 &amp;&amp; nd &amp;&amp; ((nd.sll == 00:00:00:00:00:00 || nd.sll == 52:54:00:c1:68:71) || ((nd.tll == 00:00:00:00:00:00 || nd.tll == 52:54:00:c1:68:71)))), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls2-vm4" &amp;&amp; eth.src == 52:54:00:c1:68:73 &amp;&amp; arp.sha == 52:54:00:c1:68:73), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=90   , match=(inport == "ls2-vm4" &amp;&amp; eth.src == 52:54:00:c1:68:73 &amp;&amp; ip6 &amp;&amp; nd &amp;&amp; ((nd.sll == 00:00:00:00:00:00 || nd.sll == 52:54:00:c1:68:73) || ((nd.tll == 00:00:00:00:00:00 || nd.tll == 52:54:00:c1:68:73)))), action=(next;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=80   , match=(inport == "ls2-vm3" &amp;&amp; (arp || nd)), action=(drop;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=80   , match=(inport == "ls2-vm4" &amp;&amp; (arp || nd)), action=(drop;)</span><br><span class="line">table=2 (ls_in_port_sec_nd  ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=3 (ls_in_pre_acl      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=4 (ls_in_pre_lb       ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=5 (ls_in_pre_stateful ), priority=100  , match=(reg0[0] == 1), action=(ct_next;)</span><br><span class="line">table=5 (ls_in_pre_stateful ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=6 (ls_in_acl          ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=7 (ls_in_qos_mark     ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=8 (ls_in_lb           ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=9 (ls_in_stateful     ), priority=100  , match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)</span><br><span class="line">table=9 (ls_in_stateful     ), priority=100  , match=(reg0[2] == 1), action=(ct_lb;)</span><br><span class="line">table=9 (ls_in_stateful     ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=10(ls_in_arp_rsp      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=11(ls_in_dhcp_options ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=12(ls_in_dhcp_response), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=100  , match=(eth.mcast), action=(outport = "_MC_flood"; output;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=50   , match=(eth.dst == 52:54:00:c1:68:60), action=(outport = "ls2-lr1"; output;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=50   , match=(eth.dst == 52:54:00:c1:68:71), action=(outport = "ls2-vm3"; output;)</span><br><span class="line">table=13(ls_in_l2_lkup      ), priority=50   , match=(eth.dst == 52:54:00:c1:68:73), action=(outport = "ls2-vm4"; output;)</span><br><span class="line"></span><br><span class="line">Datapath: "ls2" (85cd1eaf-5f4c-45e2-882b-11d0f96aba9e)  Pipeline: egress</span><br><span class="line"></span><br><span class="line">table=0 (ls_out_pre_lb      ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=1 (ls_out_pre_acl     ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=2 (ls_out_pre_stateful), priority=100  , match=(reg0[0] == 1), action=(ct_next;)</span><br><span class="line">table=2 (ls_out_pre_stateful), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=3 (ls_out_lb          ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=4 (ls_out_acl         ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=5 (ls_out_qos_mark    ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=6 (ls_out_stateful    ), priority=100  , match=(reg0[1] == 1), action=(ct_commit(ct_label=0/1); next;)</span><br><span class="line">table=6 (ls_out_stateful    ), priority=100  , match=(reg0[2] == 1), action=(ct_lb;)</span><br><span class="line">table=6 (ls_out_stateful    ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=7 (ls_out_port_sec_ip ), priority=0    , match=(1), action=(next;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=100  , match=(eth.mcast), action=(output;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=50   , match=(outport == "ls2-lr1"), action=(output;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=50   , match=(outport == "ls2-vm3" &amp;&amp; eth.dst == &#123;52:54:00:c1:68:71&#125;), action=(output;)</span><br><span class="line">table=8 (ls_out_port_sec_l2 ), priority=50   , match=(outport == "ls2-vm4" &amp;&amp; eth.dst == &#123;52:54:00:c1:68:73&#125;), action=(output;)</span><br></pre></td></tr></table></figure><p>其实这个逻辑流表是集中式的，是根据逻辑拓扑转换而来的流表，这个转换细节我们没去看，但是逻辑还是很清晰的，就是根据我们针对逻辑拓扑的配置，来确定哪些报文发送到哪里。而比较困难的就是这些逻辑流表怎么能转换到各个宿主机，每个宿主机都是不一样的流表。</p></div><div></div><footer class="post-footer"><div class="post-nav"><div class="post-nav-next post-nav-item"><a href="/2017/02/22/SDN/OVN/2017-02-22-ovn-nbdb/" rel="next" title="OVN Northbound DB"><i class="fa fa-chevron-left"></i> OVN Northbound DB</a></div><div class="post-nav-prev post-nav-item"> <a href="/2017/02/26/SDN/OVN/2017-02-26-ovn-flows/" rel="prev" title="OVN Logical Flows to Openflows">OVN Logical Flows to Openflows<i class="fa fa-chevron-right"></i></a></div></div></footer></div></article><div class="post-copyright"><p><span>注意:</span>所有文章非特别说明皆为原创。为保证信息与源同步，转载时请务必注明文章出处！谢谢合作 :-)</p><p> <span>原始链接:</span><a class="post-url" href="/2017/02/25/SDN/OVN/2017-02-25-ovn-sbdb/" title="OVN Southbound DB">http://zhaozhanxu.com/2017/02/25/SDN/OVN/2017-02-25-ovn-sbdb/</a><span class="copy-path" data-clipboard-text="原文: http://zhaozhanxu.com/2017/02/25/SDN/OVN/2017-02-25-ovn-sbdb/　　作者: 赵占旭" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span><script src="/js/clipboard.min.js"></script><script>var clipboard=new Clipboard(".copy-path")</script></p><p> <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/cn" title="中国大陆 (CC BY-NC-SA 4.0 CN)" target="_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。</p></div></div></div><div class="comments" id="comments"></div></div><div class="sidebar-toggle"><div class="sidebar-toggle-line-wrap"><span class="sidebar-toggle-line sidebar-toggle-line-first"></span><span class="sidebar-toggle-line sidebar-toggle-line-middle"></span><span class="sidebar-toggle-line sidebar-toggle-line-last"></span></div></div><aside id="sidebar" class="sidebar"><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap"> Table of Contents</li><li class="sidebar-nav-overview" data-target="site-overview"> Overview</li></ul><section class="site-overview sidebar-panel"><div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a href="/about"><img class="site-author-image" itemprop="image" src="/images/public/me.jpg" alt="赵占旭"><p class="site-author-name" itemprop="name">赵占旭</p><p class="site-description motion-element" itemprop="description"></p></a></div><nav class="site-state motion-element"><div class="site-state-item site-state-posts"> <a href="/archives"><span class="site-state-item-count">61</span> <span class="site-state-item-name">posts</span></a></div><div class="site-state-item site-state-categories"> <a href="/categories"><span class="site-state-item-count">7</span> <span class="site-state-item-name">categories</span></a></div><div class="site-state-item site-state-tags"> <a href="/tags"><span class="site-state-item-count">14</span> <span class="site-state-item-name">tags</span></a></div></nav><div class="feed-link motion-element"><a href="/atom.xml" rel="alternate"><i class="fa fa-rss"></i> RSS</a></div><div class="links-of-author motion-element"><span class="links-of-author-item"><a href="mailto:zhaozhanxu@163.com" target="_blank" title="Mail"><i class="fa fa-fw fa-envelope"></i> Mail</a></span><span class="links-of-author-item"><a href="https://github.com/zhaozhanxu" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i> GitHub</a></span><span class="links-of-author-item"><a href="https://www.linkedin.com/in/zhaozhanxu" target="_blank" title="LinkedIn"><i class="fa fa-fw fa-linkedin"></i> LinkedIn</a></span><span class="links-of-author-item"><a href="https://twitter.com/zhaozhanxu" target="_blank" title="Twitter"><i class="fa fa-fw fa-twitter"></i> Twitter</a></span><span class="links-of-author-item"><a href="/about/" target="_blank" title="Wechat"><i class="fa fa-fw fa-wechat"></i> Wechat</a></span><span class="links-of-author-item"><a href="/about/" target="_blank" title="QQ"><i class="fa fa-fw fa-qq"></i> QQ</a></span></div><div class="links-of-blogroll motion-element links-of-blogroll-inline"><div class="links-of-blogroll-title"><i class="fa fa-fw fa-address-book"></i> 基情链接</div><ul class="links-of-blogroll-list"><li class="links-of-blogroll-item"> <a href="http://blog.csdn.net/jqh9804" title="呆子辉" target="_blank">呆子辉</a></li></ul></div></section><section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active"><div class="post-toc"><div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#拓扑"><span class="nav-number">1.</span><span class="nav-text"><a href="#&#x62D3;&#x6251;" class="headerlink" title="&#x62D3;&#x6251;"></a> &#x62D3;&#x6251;</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Southbound-DB"><span class="nav-number">2.</span><span class="nav-text"><a href="#Southbound-DB" class="headerlink" title="Southbound DB"></a> Southbound DB</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#内容展示"><span class="nav-number">2.1.</span><span class="nav-text"><a href="#&#x5185;&#x5BB9;&#x5C55;&#x793A;" class="headerlink" title="&#x5185;&#x5BB9;&#x5C55;&#x793A;"></a> &#x5185;&#x5BB9;&#x5C55;&#x793A;</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#chassis信息展示"><span class="nav-number">2.2.</span><span class="nav-text"><a href="#chassis&#x4FE1;&#x606F;&#x5C55;&#x793A;" class="headerlink" title="chassis&#x4FE1;&#x606F;&#x5C55;&#x793A;"></a> chassis&#x4FE1;&#x606F;&#x5C55;&#x793A;</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Logical-Flow信息展示"><span class="nav-number">2.3.</span><span class="nav-text"><a href="#Logical-Flow&#x4FE1;&#x606F;&#x5C55;&#x793A;" class="headerlink" title="Logical Flow&#x4FE1;&#x606F;&#x5C55;&#x793A;"></a> Logical Flow&#x4FE1;&#x606F;&#x5C55;&#x793A;</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#LS-ingress流表展示"><span class="nav-number">2.3.1.</span><span class="nav-text"><a href="#LS-ingress&#x6D41;&#x8868;&#x5C55;&#x793A;" class="headerlink" title="LS ingress&#x6D41;&#x8868;&#x5C55;&#x793A;"></a> LS ingress&#x6D41;&#x8868;&#x5C55;&#x793A;</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#LS-egress流表展示"><span class="nav-number">2.3.2.</span><span class="nav-text"><a href="#LS-egress&#x6D41;&#x8868;&#x5C55;&#x793A;" class="headerlink" title="LS egress&#x6D41;&#x8868;&#x5C55;&#x793A;"></a> LS egress&#x6D41;&#x8868;&#x5C55;&#x793A;</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#LR-ingress流表展示"><span class="nav-number">2.3.3.</span><span class="nav-text"><a href="#LR-ingress&#x6D41;&#x8868;&#x5C55;&#x793A;" class="headerlink" title="LR ingress&#x6D41;&#x8868;&#x5C55;&#x793A;"></a> LR ingress&#x6D41;&#x8868;&#x5C55;&#x793A;</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#LR-egress流表展示"><span class="nav-number">2.3.4.</span><span class="nav-text"><a href="#LR-egress&#x6D41;&#x8868;&#x5C55;&#x793A;" class="headerlink" title="LR egress&#x6D41;&#x8868;&#x5C55;&#x793A;"></a> LR egress&#x6D41;&#x8868;&#x5C55;&#x793A;</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#逻辑流表展示"><span class="nav-number">2.3.5.</span><span class="nav-text"><a href="#&#x903B;&#x8F91;&#x6D41;&#x8868;&#x5C55;&#x793A;" class="headerlink" title="&#x903B;&#x8F91;&#x6D41;&#x8868;&#x5C55;&#x793A;"></a> &#x903B;&#x8F91;&#x6D41;&#x8868;&#x5C55;&#x793A;</span></a></li></ol></li></ol></li></ol></div></div></section></div></aside></div></main><footer id="footer" class="footer"><div class="footer-inner"><div class="copyright"> &copy; 2016 - <span itemprop="copyrightYear">2017</span><span class="with-love"><i class="fa fa-heart"></i></span> <span class="author" itemprop="copyrightHolder">赵占旭</span></div><div class="powered-by"> Powered by <a class="theme-link" href="https://hexo.io">Hexo</a></div><div class="theme-info"> Theme - <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">NexT</a></div><div class="busuanzi-count"><script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script><span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span></span><span class="site-pv"><i class="fa fa-eye"></i><span class="busuanzi-value" id="busuanzi_value_page_pv"></span></span></div></div></footer><div class="back-to-top"><i class="fa fa-arrow-up"></i></div></div><script type="text/javascript">"[object Function]"!==Object.prototype.toString.call(window.Promise)&&(window.Promise=null)</script><script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script><script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script><script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script><script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script><script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script><script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script><script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script><script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script><script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script><script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script><script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script><script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script><script type="text/javascript">function proceedsearch(){$("body").append('<div class="popoverlay">').css("overflow","hidden"),$(".popup").toggle()}var isfetched=!1,search_path="search.xml";0==search_path.length&&(search_path="search.xml");var path="/"+search_path,searchFunc=function(e,t,a){"use strict";$.ajax({url:e,dataType:"xml",async:!0,success:function(e){isfetched=!0,$(".popup").detach().appendTo(".header-inner");var r=$("entry",e).map(function(){return{title:$("title",this).text(),content:$("content",this).text(),url:$("url",this).text()}}).get(),c=document.getElementById(t),n=document.getElementById(a);c.addEventListener("input",function(){var e=0,t='<ul class="search-result-list">',a=this.value.trim().toLowerCase().split(/[\s\-]+/);n.innerHTML="",this.value.trim().length>1&&r.forEach(function(r){var c=!1,n=r.title.trim().toLowerCase(),s=r.content.trim().replace(/<[^>]+>/g,"").toLowerCase(),o=decodeURIComponent(r.url),i=-1,l=-1,p=-1;if(""!=n&&a.forEach(function(e,t){i=n.indexOf(e),l=s.indexOf(e),(i>=0||l>=0)&&(c=!0,0==t&&(p=l))}),c){e+=1,t+="<li><a href='"+o+"' class='search-result-title'>"+n+"</a>";var h=r.content.trim().replace(/<[^>]+>/g,"");if(p>=0){var u=p-20,d=p+80;u<0&&(u=0),0==u&&(d=50),d>h.length&&(d=h.length);var f=h.substring(u,d);a.forEach(function(e){var t=new RegExp(e,"gi");f=f.replace(t,'<b class="search-keyword">'+e+"</b>")}),t+='<p class="search-result">'+f+"...</p>"}t+="</li>"}}),t+="</ul>",0==e&&(t='<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'),""==a&&(t='<div id="no-result"><i class="fa fa-search fa-5x" /></div>'),n.innerHTML=t}),proceedsearch()}})};$(".popup-trigger").click(function(e){e.stopPropagation(),0==isfetched?searchFunc(path,"local-search-input","local-search-result"):proceedsearch()}),$(".popup-btn-close").click(function(e){$(".popup").hide(),$(".popoverlay").remove(),$("body").css("overflow","")}),$(".popup").click(function(e){e.stopPropagation()})</script><script>!function(){var t=document.createElement("script"),e=window.location.protocol.split(":")[0];t.src="https"===e?"https://zz.bdstatic.com/linksubmit/push.js":"http://push.zhanzhang.baidu.com/push.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(t,s)}()</script></body></html>